<?php

namespace app\common\func;

use EasyWeChat\Factory;

class WeChat
{

    private $app;

    public function __construct()
    {
        $config = [
            'app_id' => 'wx9884c18025df7346',
            'secret' => 'f84d6b6c06e39043bd101bfca48ed6b3',

            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',

            //...
        ];

        $this->app = Factory::officialAccount($config);
    }

    public function getUser($openId){
        return $this->app->user->get($openId);
    }
}
